package com.erps.dao;

import com.erps.CommonUtils.ActiveField;
import com.erps.CommonUtils.DateUtils;
import com.erps.CommonUtils.JActiveField;
import com.erps.CommonUtils.JActiveTable;
import com.erps.CommonUtils.Sequence;
import com.erps.db.DBManager;
import com.hmkj.entity.ErspResOnline;

public class ErspResOnlineDao extends JActiveTable {
	public ErspResOnlineDao() {
		this.setDBTableName("ersp_res_online");
		AddField(new JActiveField("id", "id", ActiveField.ftString, 36));
		setDefaultFieldValue("id", Sequence.getGuid());
		AddField(new JActiveField("res_id", "res_id", ActiveField.ftString, 36));
		AddField(new JActiveField("res_prozone", "res_prozone", ActiveField.ftString, 36));
		AddField(new JActiveField("res_onlinetype", "res_onlinetype", ActiveField.ftString, 20));
		AddField(new JActiveField("res_viewtype", "res_viewtype", ActiveField.ftString, 20));
		AddField(new JActiveField("res_size", "res_size", ActiveField.ftString, 100));
		AddField(new JActiveField("res_language", "res_language", ActiveField.ftString, 100));
		AddField(new JActiveField("res_copyright", "res_copyright", ActiveField.ftString, 200));
		AddField(new JActiveField("res_request_type", "res_request_type", ActiveField.ftString, 100));
		AddField(new JActiveField("res_request_url", "res_request_url", ActiveField.ftString, Integer.MAX_VALUE));
		AddField(new JActiveField("res_requirement", "res_requirement", ActiveField.ftString, 200));
		
		
		AddField(new JActiveField("last_update_time", "last_update_time", ActiveField.ftLong));
		setDefaultFieldValue("last_update_time", String.valueOf(DateUtils.getDayTimeNum()));
        setDbKeyFields("id");
	}

	public int add(ErspResOnline vo) {
		setFieldValue("id", vo.getId());
		setFieldValue("res_id", vo.getRes_id());
		setFieldValue("res_prozone", vo.getRes_prozone());
		setFieldValue("res_onlinetype", vo.getRes_onlinetype());
		setFieldValue("res_viewtype", vo.getRes_viewtype());
		setFieldValue("res_size", vo.getRes_size());
		setFieldValue("res_language", vo.getRes_language());
		setFieldValue("res_copyright", vo.getRes_copyright());
		setFieldValue("res_request_type", vo.getRes_request_type());
		setFieldValue("res_request_url", vo.getRes_request_url());
		setFieldValue("res_requirement", vo.getRes_requirement());
		
		return DBManager.ExecSQL(this.getSQL());
	}

	public String getSQL(ErspResOnline vo) {
		setFieldValue("id", vo.getId());
		setFieldValue("res_id", vo.getRes_id());
		setFieldValue("res_prozone", vo.getRes_prozone());
		setFieldValue("res_onlinetype", vo.getRes_onlinetype());
		setFieldValue("res_viewtype", vo.getRes_viewtype());
		setFieldValue("res_size", vo.getRes_size());
		setFieldValue("res_language", vo.getRes_language());
		setFieldValue("res_copyright", vo.getRes_copyright());
		setFieldValue("res_request_type", vo.getRes_request_type());
		setFieldValue("res_request_url", vo.getRes_request_url());
		setFieldValue("res_requirement", vo.getRes_requirement());
		
		return this.getSQL();
	}
}
